/**
 * TOPCODER SRM 512 Division II Level 1 (256 points)
 * http://community.topcoder.com/stat?c=problem_statement&pm=11287&rd=14537
 */
		

package topcoder;

import java.util.Arrays;

public class MarbleDecoration {

	public int maxLength(int R, int G, int B){
		
		int c1,c2;
		if(R>=G && R>=B){
			c1=R;
			if(G>=B)
				c2=G;
			else
				c2=B;
		}
		else if(G>=R && G>=B){
			c1=G;
			if(R>=B)
				c2=R;
			else
				c2=B;
		}
		else{
			c1=B;
			if(R>=G)
				c2=R;
			else
				c2=G;
		}
		
		if(c1==c2)
			return c1+c2;
		else
			return c2*2+1;
	}
	
	
	/**
	 * More compact version
	 */
	public int maxLength2(int R, int G, int B){
		
		int[] r = {R,G,B};
		Arrays.sort(r);
		
		if(r[1]==r[2])
			return r[1] + r[2];
		else
			return r[1]*2 + 1;
	}
}
